#include "module_port.h"
#include "ui_module_port.h"

#include "module/property/module_port_property.h"
#include "mainwindow.h"
#include "ui_mainwindow.h"

module_port::module_port(QWidget *parent) :
    QFrame(parent),
    ui(new Ui::module_port)
{
    ui->setupUi(this);
}

module_port::~module_port()
{
    delete ui;
}

void module_port::on_pushButton_clicked()
{
    module_port_property *new_property = new module_port_property();
    new_property->setObjectName("module_property");

    new_property->set_InOut(this->port_style.InOut);
    new_property->set_name(this->port_style.name);

    this->delete_propertys();

    MainWindow::mywindow->ui->gridLayout_property->addWidget(new_property, 0, 0);

    new_property->show();
}

void module_port::set_style(module_port_style style)
{
    this->set_name(style.name);
    this->set_InOut(style.InOut);
}

void module_port::set_name(QString name)
{
    this->port_style.name = name;
}

QString module_port::get_name()
{
    return this->port_style.name;
}

void module_port::set_InOut(QString InOut)
{
    this->port_style.InOut = InOut;
}

QString module_port::get_InOut()
{
    return this->port_style.InOut;
}

void module_port::set_datasize(int datasize)
{
    this->port_style.datasize = datasize;
}

int module_port::get_datasize()
{
    return this->port_style.datasize;
}

void module_port::set_type(QString type)
{
    this->port_style.type = type;
}

QString module_port::get_type()
{
    return this->port_style.type;
}
